package com.yanyeori.framework.security.config;

import com.yanyeori.framework.security.configprop.SecurityConfigProps;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Config Factory
 *
 * @author chenkuan 2021/1/11
 */
public class ConfigFactory implements InitializingBean {

    private final SecurityConfigProps config;
    private final RedisTemplate<String, Object> redisTemplate;

    private static ConfigFactory instance;

    public ConfigFactory(SecurityConfigProps config, RedisTemplate<String, Object> redisTemplate) {
        this.config = config;
        this.redisTemplate = redisTemplate;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        instance = this;
    }

    public static SecurityConfigProps getConfig() {
        return instance.config;
    }

    public static RedisTemplate<String, Object> getRedisTemplate() {
        return instance.redisTemplate;
    }
}
